import { Component, OnInit } from '@angular/core';
import { AxiosService } from '../../axios.service';
import { LocalStorageService } from 'src/app/myService/local-storage.service';
import { Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { async } from 'q';
import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
import CONFIG from '../../../assets/config/config.json'

@Component({
  selector: 'app-emp-zuzhuang',
  templateUrl: './emp-zuzhuang.component.html',
  styleUrls: ['./emp-zuzhuang.component.scss']
})
export class EmpZuzhuangComponent implements OnInit {
  isLoading;


  //所有工单数据
  public tempData = [];

  public listOfData = [];//工单文件区数据

  fileInfom;//显示工单对应的文件信息
  isOkLoadingfileInfom;

  public fileList;//选择要上传的文件
  public workName;
  uploader;
  fileName;//文件名
  workerName;//工件名
  link;
  workOrder;//上传对应的工单号
  sheet_order;//工件上传
  keykey;
  public unionorder: any;//工单号,
  public newValue: any;//"新值"
  name;//"表中栏位名称"

  addRemark1;//编辑设计备注
  isOkLoadingRemark;
  designRemark;


  splitJudge: string = ',';
  fileInfom2;
  imglist;

  numberhao;
  // 接收要修改的数据
  updateData;

  first: any;//首个19码
  tail: any;//结尾19码
  uploadData; // 上传数据

  public workData = [];
  //意同workData
  public dataWork = [];
  public selCNCData = [];

  isShow = [];
  btnStop = [];
  btnStart = [];

  value;//计时时间值
  totalTime;//数据库中的时间
  time;//页面的时间
  recordRowClick = -1;

  //其他备注
  addOtherRemark;
  isOkLoadingOthRemark;
  RemarkValue;//备注框的值
  workKey;

  showWarning = {};//工件行显示退回图标
  showBigWarning = [];//工单行显示退回图标

  isSendVisible;//送出工件
  isSendOkLoading;

  isFileVisible;//删除文件信息
  isFileOkLoading;
  id;//文件信息id

  isFileVisible2;
  gdid;
  unionorder2;
  workerName2;

  timeIndex = 0;
  hour;
  minutes;
  seconds;
  timeKey: any = [];

  unionKey;
  smallKey;
  timeDic = {};
  searchValue = ''; //筛选框输入的内容
  ishowerer = [];
  sfmtime = "00:00:00"
  sjkg = false;
  kssj;
  jsq;
  min = 0;
  cdcd;
  dlyy;
  dlyynr;
  dlyysz = [];
  // 工号
  jobNo;
  addDlyy;
  dlyyadd;
  addOtherRemark2;
  //1號機台 2號機台 3號機台 4號機台
  selectStatus = [
    { 'name': 'ALL', 'checked': true, 'select': '' },
    { 'name': '1號機台', 'checked': true, 'select': '1號機 ' },
    { 'name': '2號機台', 'checked': true, 'select': '2號機 ' },
    // { 'name': '3號機台', 'checked': true, 'select': '3號機 ' },
    { 'name': '4號機台', 'checked': true, 'select': '4號機 ' },
    { 'name': '5號機台', 'checked': true, 'select': '5號機 ' },
    { 'name': '6號機台', 'checked': true, 'select': '6號機 ' },
    { 'name': '7號機台', 'checked': true, 'select': '7號機 ' },
    // { 'name': '8號機台', 'checked': true, 'select': '8號機 ' },
    { 'name': '9號 走芯機', 'checked': true, 'select': '9號 走芯機' }
  ];
  radioValue; // 退回单选框
  listfd = [];

  constructor(
    public axios: AxiosService,
    private storage: LocalStorageService,
    public activatedRoute: ActivatedRoute,
    private router: Router
  ) {
    this.activatedRoute.params.subscribe((data) => {
      if (data) {
        console.log("----------------------------\n", data)
        // this.nameTitle = data.name;
        // console.log(this.nameTitle)
      }
    })
  }

  ngOnInit(): void {
    //获取全部数据
    this.getAllData();
  }

  isWarning(date1Str):boolean {
    const date1 = new Date(date1Str);  // 将日期字符串转换为 Date 对象
    const date2 = new Date();  // 创建表示当前时间的 Date 对象

    // 获取时间戳并计算毫秒差值
    const timeDiff = Math.abs(date1.getTime() - date2.getTime());

    // 将毫秒差值转换为天数（毫秒 * 秒 * 分 * 时 * 天）
    const dayDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));

    // console.log(dayDiff);

    if (dayDiff <= CONFIG['days']) return true;
    else return false;
  }

  //获取全部数据
  getAllData() {
    this.jobNo = this.storage.getStorageData('user').job_no;
    console.log(this.jobNo)
    this.axios.axiosPost('QueryUnionOrderByStatusStage', { "stage": 5, "stageValue": 1, "status": 5, 'job_no': this.jobNo, box: this.searchValue })
      .then((data) => {
        if (data) {
          // debugger
          this.ishowerer = [];
          this.listfd = [];
          console.log(data)

          this.tempData = data['order'];
          this.cdcd = this.tempData.length;

          for (let i = 0; i < this.tempData.length; i++) {
            this.tempData[i].show = false;
            this.listfd.push(new Array)
            // 实际时间栏位把秒转为小时
            this.tempData[i].zuzhuang_shijian = Number(this.tempData[i].zuzhuang_shijian) / 3600;
            console.log(this.tempData[i].zuzhuang_shijian)
            if (this.tempData[i].zuzhuang_shijian > 0.00) {
              this.tempData[i].zuzhuang_shijian = Math.floor((this.tempData[i].zuzhuang_shijian + 0.01) * 100) / 100;
            }
            console.log(this.tempData[i].zuzhuang_shijian)
            this.ishowerer.push(false)

            console.log(data['order'][i].tip)
            // debugger
            if (this.tempData[i].tip > 0) {
              this.showBigWarning.push(true);
            } else {
              this.showBigWarning.push(false);
            }
          }
          this.storage.setStorageData('result', this.tempData);
          // this.QueryWorkOrder();
        }
      })
      .catch((err) => {
        console.log(err);
      })
  }

  //查询工单对应的工件信息
  QueryWorkOrder(key) {
    if (this.tempData[key].show == true) {
      this.tempData[key].show = false;
    } else {
      this.tempData[key].show = true;
    }
    this.unionKey = key;
    this.workKey = key;
    this.axios.axiosPost('QueryWorkOrder', { 'unionorder': this.tempData[key].union_order, "status": 5, "box": this.searchValue })
      .then((data) => {
        console.log(data)
        if (data['result'] === 'ok' && data['order'].length > 0) {
          // debugger
          this.listfd[key] = new Array;
          const orderData = data['order'];
          let a = data['order']
          this.workData[key] = a;
          this.dataWork = a;
          console.log(this.workData)
          const tempArr = [];
          const timeDefault = [];
          for (let i = 0; i < orderData.length; i++) {
            this.listfd[key].push(new Array)
            if (orderData[i]['remark'] !== '') {
              tempArr.push(true);
            } else {
              tempArr.push(false);
            }

            // 给点击的小行数据初始化时间
            timeDefault.push('');
          }
          this.showWarning[key] = tempArr;
          this.timeDic[this.unionKey] = timeDefault;

        }
      })
      .catch((err) => {
        console.log(err);
      })
  }

  //CNC机台选择
  selStatus(item) {
    item.checked = !item.checked;
    this.selCNC(item);
  }

  //筛选CNC机台
  selCNC(data) {
    // debugger
    // console.log(data,this.tempData['union_order'])
    // this.axios.axiosPost('QueryCncData', { 'unionorder': this.tempData['union_order'], 'cnc': data.select})
    //   .then((data) => {
    //     console.log(data)
    //     if (data['result'] === 'ok') {
    //       this.tempData = data['order'];
    //     }
    //   })

    // 选中
    if (data.checked) {
      const addCNC = this.dataWork.filter(res => res['cnc_name'] === data.select);
      console.log(addCNC)
      this.selCNCData = this.selCNCData.concat(addCNC);
      console.log(this.selCNCData)
    }
    // 未选中
    if (!data.checked) {
      const deleteCNC = this.workData.filter(res => res['cnc_name'] === data.select);
      console.log(deleteCNC)
      this.selCNCData = this.workData.filter(item => !deleteCNC.some(ele => ele['cnc_name'] === item['cnc_name']));
      console.log(this.selCNCData)
    }
    // this.workData = [];
    this.workData = this.selCNCData;
  }




  //点击设计备注
  addRemark(item) {
    this.addRemark1 = true;
    this.designRemark = item.assemble_remark;
    this.updateData = item;
    this.axios.axiosPost("QueryBeizhuInfo")
      .then((data) => {
        console.log(data);
        if (data['result'] === 'ok') {
          this.dlyy = data["order"]
          for (var i = 0; i < this.dlyy.length; i++) {
            this.dlyy[i].show = false
          }
          console.log(this.dlyy)
          if (this.designRemark.split(",")) {
            this.dlyysz = this.designRemark.split(",");
            console.log(this.dlyysz)
            for (var i = 0; i < this.dlyysz.length; i++) {
              for (var y = 0; y < this.dlyy.length; y++) {
                if (this.dlyysz[i] == this.dlyy[y].name) {
                  this.dlyy[y].show = true;
                }
              }
            }
          }

        }

      })
      .catch((err) => {
        console.log(err);
      });
  }
  //确认添加设计备注
  addRemarkOk() {
    this.isOkLoadingRemark = true;
    this.addRemark1 = false;
    this.isOkLoadingRemark = false;

    console.log(this.first);
    this.axios.axiosPost('UpdateUnionOrder', { 'unionorder': this.updateData.union_order, 'name': 'assemble_remark', 'newValue': this.dlyynr })
      .then((data) => {
        console.log(data)
        if (data['result'] === 'ok') {
          this.updateData.assemble_remark = this.dlyynr;
          this.getAllData();
        }
      })
  }

  //取消添加设计备注
  CancelAddRemark() {
    this.addRemark1 = false;
    for (var i = 0; i < this.dlyy.length; i++) {
      this.dlyy[i].show = false
    }
  }
  bzclick(name) {
    console.log(name)
    console.log(this.dlyy)
    this.dlyysz = []
    for (var i = 0; i < this.dlyy.length; i++) {
      if (this.dlyy[i].show == true) {
        this.dlyysz.push(this.dlyy[i].name)
      }
    }
    this.dlyynr = this.dlyysz.join(",")
    console.log(this.dlyynr)
  }

  currentPageDataChange(qqq) {

  }

  //点击图标显示此工单的文件信息
  downLoad(infom) {
    console.log(infom)
    this.fileInfom = true;
    // this.updateData = infom;
    // debugger
    this.workOrder = infom.union_order;
    this.workerName = infom.name;
    this.workName = this.workOrder;
    this.sheet_order = infom.sheet_order;
    console.log(infom.name, this.workOrder)
    if (infom.name !== undefined) {
      this.axios.axiosPost('QueryWorkFiles', { 'unionorder': this.workOrder, 'workorder': infom.name })
        .then((data) => {
          console.log(data)
          if (data['result'] === 'ok') {
            this.listOfData = data['files'];
          }
        })
    } else if (infom.name === undefined) {
      this.axios.axiosPost('QueryWorkFiles', { 'unionorder': this.workOrder, 'workorder': this.sheet_order })
        .then((data) => {
          console.log(data)
          if (data['result'] === 'ok') {
            this.listOfData = data['files'];
          }
        })
    }
  }

  CancelShow() {
    this.fileInfom = false;
  }

  ShowOK() {
    this.isOkLoadingfileInfom = true;
    this.fileInfom = false;
    this.isOkLoadingfileInfom = false;
  }

  //上传文件
  Upload() {
    // debugger
    if (this.uploadData == null)
      return;
    console.log(this.workOrder, this.workerName)
    if (this.workerName !== undefined) {
      this.isLoading = true;
      this.axios.axiosPost('Upload', {
        'unionorder': this.workOrder, 'workorder': this.workerName,
        'filename': this.fileName.files[0]['name'], 'filedata': this.uploadData
      })
        .then((data) => {

          console.log(data)
          if (data['result'] === 'ok') {
            this.isLoading = false;
            alert("上传成功！")
            this.uploadData = null;
            this.axios.axiosPost('QueryWorkFiles', { 'unionorder': this.workOrder, 'workorder': this.workerName })
              .then((data) => {
                if (data['result'] === 'ok') {
                  this.listOfData = data['files'];
                }
              })

          } else {
            this.isLoading = false;
            alert(data["description"])
          }
        }).catch(function (err) {
          console.log(err)
        })
    } else if (this.workerName === undefined) {
      this.isLoading = true;
      this.axios.axiosPost('Upload', {
        'unionorder': this.workOrder, 'workorder': this.sheet_order,
        'filename': this.fileName.files[0]['name'], 'filedata': this.uploadData
      })
        .then((data) => {

          console.log(data)
          if (data['result'] === 'ok') {
            this.isLoading = false;
            alert("上传成功！")
            this.uploadData = null;
            this.axios.axiosPost('QueryWorkFiles', { 'unionorder': this.workOrder, 'workorder': this.sheet_order })
              .then((data) => {
                if (data['result'] === 'ok') {
                  this.listOfData = data['files'];
                }
              })

          } else {
            this.isLoading = false;
            alert(data["description"])
          }
        }).catch(function (err) {
          console.log(err)
        })
    }
  }

  //选择要上传的文件名
  openFile(event: any): void {
    // debugger
    this.fileName = event.target; //获取点击得到的对象
    const reader = new FileReader();
    reader.onload = (() => {
      if (reader.result) {
        this.uploadData = reader.result;
        console.log(reader.result);
      }
    });
    reader.readAsDataURL(this.fileName.files[0]);//将文件转为Base64格式
    console.log("hahahaahahahah\n", reader.result)
  }

  handleFileCancel() {
    this.isFileVisible = false;
  }

  downLoadFile(data) {
    console.log(data)
    // debugger
    this.fileName = data.file_name;
    this.link = this.axios.domainTest1 + this.workName + '/' + this.fileName;
    console.log(this.fileName, this.link)
  }

  //删除文件信息
  showDelFile(data) {
    this.isFileVisible = true;
    console.log(data)
    this.id = data.id;
  }

  delFileOk() {
    this.isFileOkLoading = true;
    this.isFileVisible = false;
    this.isFileOkLoading = false;
    this.axios.axiosPost('DeleteWorkFile', { 'id': this.id })
      .then((data) => {
        console.log(data)
        if (data['result'] === 'ok') {
          let listData = this.listOfData.filter(res => res['id'] !== this.id)
          this.listOfData = listData;
        }
      })
  }



  //点击行显示计时器
  clickLine(key, item2) {
    console.log(item2);
    console.log(new Date().getTime());

    for (var i = 0; i < this.ishowerer.length; i++) {
      if (this.ishowerer[i] == true && i != key) {
        this.min++;
      }
    }
    if (this.min == 0) {
      this.ishowerer[key] = true;
      this.min = 0;
      if (item2) {
        this.jsq = setInterval(() => {
          // console.log(new Date().getTime() - item2);
          this.sfmtime = this.timeof(new Date().getTime() - item2 * 1000);
        }, 1000);
      } else {
        this.sfmtime = "00:00:00"
      }
    } else {
      this.ishowerer[key] = false;
      this.min = 0;
    }
    // console.log(this.ishowerer);

  }

  //开始计时
  start(item, key) {

    if (this.sjkg == false) {
      this.sjkg = true;
      if (this.sfmtime == "00:00:00") {
        this.axios.axiosPost("UpdateUnionOrder", {
          unionorder: item.union_order,
          name: "priority",
          newValue: new Date().getTime() / 1000,
        }).then((data) => {
          console.log(data);
          this.tempData[key].priority = new Date().getTime() / 1000
          this.clickLine(key, item.priority)
        })
      } else {
        alert("已經開始計時了")
      }
    } else {
      alert("已經開始計時，請勿重復操作")
    }
    // console.log(key)
    // this.btnStop[key] = true;
    // this.btnStart[key] = false;
    // console.log('00000000000000 \n', this.btnStart)
    // // this.setTime();
    // // timeIndex = 0;
    // console.log(item.sheji_shijian)
    // this.value = setInterval(setTime, 1000);
  }

  //结束计时
  end(item, key) {
    if (item.priority || this.sfmtime != "00:00:00") {
      clearInterval(this.jsq);
      this.ishowerer[key] = false;
      this.min = -1;
      this.sjkg = false;
      this.axios
        .axiosPost("AddWorkTime", {
          unionorder: item.union_order,
          endtime: new Date().getTime(),
          stage: 5,
        })
        .then((data) => {
          console.log(data);
          if (data["result"] === "ok") {
            console.log(this.tempData[key]);
            this.tempData[key].priority = "";
            console.log("真棒");
            this.sfmtime = "00:00:00";
            this.getAllData();
          }
        })
        .catch((err) => {
          console.log(err);
        });
    } else {
      alert("此工單未開始計時")
    }

    // this.btnStart[key] = false;
    // this.btnStop[key] = true;
    // // debugger
    // if (item.sheji_shijian === '') {
    //   item.sheji_shijian = 0;
    //   this.totalTime = item.sheji_shijian;
    // } else {
    //   this.totalTime = item.sheji_shijian;
    // }
    // console.log(this.totalTime)
    // // debugger
    // console.log(item, document.getElementsByClassName('sp')[0].innerHTML)
    // this.time = document.getElementsByClassName('sp')[0].innerHTML;
    // var hour = this.time.split(':')[0];
    // var min = this.time.split(':')[1];
    // var sec = this.time.split(':')[2];
    // var s;
    // s = Number(hour * 3600) + Number(min * 60) + Number(sec);
    // // var total;
    // // total =  parseInt(this.totalTime) + s;
    // // console.log(total,parseInt(this.totalTime))
    // this.recordRowClick = -1;
    // clearInterval(this.value);
    // this.value = null;

    // console.log('11111111111\n', this.isShow)
  }

  timeof(data) {
    var s;
    var hours: number;
    // hours=parseInt((1000 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    hours = parseInt((data % (1000 * 60 * 60 * 24) / (1000 * 60 * 60)).toString())
    // parseInt((1000 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
    console.log(hours)
    var minutes = parseInt(((data % (1000 * 60 * 60)) / (1000 * 60)).toString());
    var seconds = parseInt(((data % (1000 * 60)) / 1000).toString());
    s = (hours < 10 ? ('0' + hours) : hours) + ':' + (minutes < 10 ? ('0' + minutes) : minutes) + ':' + (seconds < 10 ? ('0' + seconds) : seconds);
    console.log(s)
    return s;
  }

  //结束页面生命周期
  ngOnDestroy(): void {
    //Called once, before the instance is destroyed.
    //Add 'implements OnDestroy' to the class.
    clearInterval(this.jsq);

  }
  //退回工件
  return(item) {
    if (!item.priority) {
      this.unionorder = item.union_order;
      if (item.bypass != "true") {
        this.addOtherRemark = true;
        // console.log(item)
        this.RemarkValue = item.other_remark + this.storage.getStorageData('user').name + ":"
      } else {
        this.addOtherRemark2 = true;
      }
    } else {
      alert("該工單未停止計時")
    }

  }

  //取消备注
  CancelRemark() {
    this.addOtherRemark = false;
  }

  //添加其他备注（退回）
  RemarkOk() {
    if (this.RemarkValue.length != 0) {
      console.log(this.RemarkValue)

      // debugger
      this.isOkLoadingOthRemark = true;
      this.addOtherRemark = false;
      this.isOkLoadingOthRemark = false;
      console.log(this.radioValue)
      if (this.radioValue == undefined) {
        alert("未指定退单位置")
      } else if (this.radioValue == "治具設計") {

        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "other_remark", "newValue1": this.RemarkValue }).then((data) => {
          console.log(data)
        })

        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "stage", "newValue1": 0, "stageValue": 1, "newValue12": 5, "stageValue2": 0 }).then((data) => {
          console.log(data, "工单状态修改成功了,取消了当前工单状态")
        })
        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "zuzhuang_endtime", "newValue1": "", "name2": "ercijg_endtime", "newValue2": "" }).then((data) => {
          console.log(data, "取消组装,二次加工时间栏位")
        })
        this.axios.axiosPost('UpdateWorkOrder', {
          'unionorder': this.unionorder, 'status': 0, "tuidan": 1
        })
          .then((data) => {
            console.log(data)
            if (data['result'] === 'ok') {
              this.getAllData();

            }
          })
          .catch((err) => {
            console.log(err);
          })

      } else if (this.radioValue == "治具加工") {
        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "zuzhuang_endtime", "newValue1": "", "name2": "ercijg_endtime", "newValue2": "" }).then((data) => {
          console.log(data, "取消组装,二次加工时间栏位")
        })
        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "other_remark", "newValue1": this.RemarkValue }).then((data) => {
          console.log(data)
        })
        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "stage", "newValue1": 2, "stageValue": 1, "newValue12": 5, "stageValue2": 0 }).then((data) => {
          console.log(data, "工单状态修改成功了,取消了当前工单状态")
        })

        this.axios.axiosPost('UpdateWorkOrder', {
          'unionorder': this.unionorder, 'status': 2
        })
          .then((data) => {
            console.log(data)
            if (data['result'] === 'ok') {
              this.getAllData();

            }
          })
          .catch((err) => {
            console.log(err);
          })

      }
    } else {
      alert("請輸入退單備註")
    }

  }
  //点击工单号显示CNC
  showCNC(item) {
    debugger
    console.log(item)
    const data = {};
    data['union_order'] = item.union_order;
    this.router.navigate(['/CNC', data])
  }

  //送出按钮
  send(item) {
    console.log(item);
    if (item.engineer_zuzhuang == "") {
      alert("未指派工程師")
    } else {
      if (!item.priority) {

        this.isSendVisible = true;
        this.unionorder = item.union_order;
        this.workerName = item.sheet_order;
      } else {
        alert("該工單未停止計時")
      }
    }
  }

  //取消送出
  handleSendCancel() {
    this.isSendVisible = false;
  }

  //确认送出
  sendOk() {
    var kg = false;
    this.axios.axiosPost("QueryWorkOrder", { 'unionorder': this.unionorder, "status": 5 }).then((data) => {
      console.log(data)
      for (var i = 0; i < data["order"].length; i++) {
        if (data["order"][i].box) {
          kg = true;
        }
      }
      if (kg == false) {
        this.isSendOkLoading = true;
        this.isSendVisible = false;
        this.isSendOkLoading = false;
        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "stage", "newValue1": 5, "stageValue": 0, "newValue12": 6, "stageValue2": 1, "name2": "songjian_time", "newValue2": "" }).then((data) => {
          console.log(data, "工单状态修改成功了,取消了当前工单状态")
        })

        this.axios.axiosPost('UpdateWorkOrder', {
          'unionorder': this.unionorder, 'status': 6
        })
          .then((data) => {
            console.log(data)
            if (data['result'] === 'ok') {
              this.getAllData();

            }
          })
          .catch((err) => {
            console.log(err);
          })
      } else {
        alert("工單下工件未解綁")
      }
    })

  }

  //计时器
  setTime(timeIndex, timeDic) {
    // debugger
    console.log(1111111)
    this.hour = Math.floor(this.timeIndex / 3600);
    this.minutes = Math.floor((this.timeIndex - this.hour * 3600) / 60);
    this.seconds = this.timeIndex - this.hour * 3600 - this.minutes * 60;
    this.hour = this.hour < 10 ? "0" + this.hour : this.hour;
    this.minutes = this.minutes < 10 ? "0" + this.minutes : this.minutes;
    this.seconds = this.seconds < 10 ? "0" + this.seconds : this.seconds;
    this.timeIndex = this.timeIndex + 1;
    console.log(222222)
    const temptime = (this.hour + ":" + this.minutes + ":" + this.seconds).toString();
    console.log('temptime ==== \n', temptime);
    timeDic[this.unionKey].splice(this.smallKey, 1, temptime);
    console.log('水水水水水水水水水水水水  \n', timeDic);
  }

  btn_CNC(data) {
    console.log(data)
    const CNCnum = {};
    CNCnum['select'] = data.select;
    console.log(CNCnum['select'])
    this.router.navigate(['/CNC', CNCnum]);
  }
  //箱号筛选
  search() {
    this.getAllData();
  }

  //点击箱号跳转
  showBox(item, key) {
    // console.log(item)
    // const data = {};
    // data['box'] = item.box;
    // data['unionorder'] = item.unionorder;
    // this.router.navigate(['/zhijianChild', data]);
    this.keykey = key
    this.isFileVisible2 = true;
    this.numberhao = item.box;
    this.gdid = item.size_width
    this.unionorder2 = item.union_order;
    this.workerName2 = item.sheet_order;
  }
  delFileOk2() {
    this.isFileVisible2 = false;
    console.log(this.unionorder2, this.workerName2)
    this.axios.axiosPost("UpdateCncData", { "unionorder": this.unionorder2, "workorder": this.workerName2, "box": "", "leo": 1 }).then((data) => {
      console.log(data, "第一个修改")
      this.QueryWorkOrder(this.keykey)

    }).catch((err) => {
      console.log(err)
    })



  }
  handleFileCancel2() {
    this.isFileVisible2 = false;
  }

  reset() {
    this.searchValue = '';
    this.getAllData();
  }

  downLoad2(infom) {
    console.log(infom)
    this.fileInfom2 = true;
    this.link = this.axios.domainTest1;
    console.log(this.link)

    if (infom.imagefile) {
      this.imglist = infom.imagefile.split(",")
    } else {
      this.imglist = [];
    }
  }
  CancelShow2() {
    this.fileInfom2 = false;
  }
  ShowOK2() {
    this.fileInfom2 = false;
  }
  QueryWorkOrder2(a, b, c) {
    console.log("触发", a)
    this.axios.axiosPost("QueryCncDataSubOrder", { "unionorder": a.unionorder, "workorder": a.workorder, status: 5 }).then((data) => {
      console.log(data);
      if (data["result"] == "ok") {
        this.listfd[b][c] = data["order"];
      }
    })
  }
  addRemarkDelete() {
    console.log(this.dlyy);
    for (var i = 0; i < this.dlyy.length; i++) {
      if (this.dlyy[i].show == true) {
        this.dlyy[i].show == false;
        this.axios.axiosPost("DeleteBeizhuInfo", { name: this.dlyy[i].name }).then((data => {
          this.addRemark(this.updateData)
        }))
      }
    }


  }
  addRemarkAdd() {
    this.addDlyy = true;

  }
  // 取消——添加————添加设计备注
  addRemarkAddCancel() {
    this.addDlyy = false;
  }
  // 确定——添加————添加设计备注
  addRemarkAddOk() {
    this.addDlyy = false;
    this.axios.axiosPost("AddBeizhuInfo", { name: this.dlyyadd })
      .then((data) => {
        console.log(data);
        if (data['result'] === 'ok') {
          this.addRemark(this.updateData)
        }
      })
      .catch((err) => {
        console.log(err);
      });
    this.addRemarkAddCancel()
    this.dlyyadd = ""
  }
  CancelRemark2() {
    this.addOtherRemark2 = false
  }
  RemarkOk2() {
    this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "stage", "newValue1": 1, "stageValue": 1, "newValue12": 4, "stageValue2": 0, "name2": "bypass", "newValue2": "false" }).then((data) => {
      console.log(data, "工单状态修改成功了,取消了当前工单状态")
    })
    this.axios.axiosPost('UpdateWorkOrder', { 'unionorder': this.unionorder, 'status': 1 }).then((data) => {
      console.log(data)
      if (data['result'] === 'ok') {
        this.addOtherRemark2 = false
        location.reload();

      }
    })
      .catch((err) => {
        console.log(err);
      })
  }
}

